home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 April / EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso / EARCD / text / hyper / hsc_source.lha / hsc / source / hsclib / linit.c < prev    next >
C/C++ Source or Header  |  1996-11-12  |  17KB  |  643 lines

  1. /*
  2.  * hsclib/linit.c
  3.  *
  4.  * functions to init & read preferences for a hsc-process
  5.  *
  6.  * Copyright (C) 1996  Thomas Aglassinger
  7.  *
  8.  * This program is free software; you can redistribute it and/or modify
  9.  * it under the terms of the GNU General Public License as published by
  10.  * the Free Software Foundation; either version 2 of the License, or
  11.  * (at your option) any later version.
  12.  *
  13.  * This program is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  * GNU General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU General Public License
  19.  * along with this program; if not, write to the Free Software
  20.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  *
  22.  * updated: 12-Nov-1996
  23.  * created: 19-Feb-1996
  24.  */
  25.  
  26. #include "hsclib/inc_base.h"
  27.  
  28. #include "hsclib/deftag.h"
  29. #include "hsclib/include.h"
  30. #include "hsclib/parse.h"
  31.  
  32. #include "hsclib/tag_a.h"
  33. #include "hsclib/tag_hsc.h"
  34. #include "hsclib/tag_if.h"
  35. #include "hsclib/tag_macr.h"
  36. #include "hsclib/tag_misc.h"
  37.  
  38. #include "ugly/fname.h"
  39.  
  40. #if DEBUG
  41. /*
  42.  * debugging print functions
  43.  */
  44. static VOID prt_ent(FILE * stream, APTR data)
  45. {
  46.     HSCENT *ent = (HSCENT *) data;
  47.  
  48.     if (ent)
  49.     {
  50.         fprintf(stream, " %s", ent->name);
  51.         if (ent->replace)
  52.             fprintf(stream, "=%s", ent->replace);
  53.         if (ent->numeric)
  54.             fprintf(stream, "=%ld", ent->numeric);
  55.     }
  56.     else
  57.         fprintf(stream, " <NULL>");
  58. }
  59.  
  60. static VOID prt_tag(FILE * stream, APTR data)
  61. {
  62.     if (data)
  63.     {
  64.         HSCTAG *tag = (HSCTAG *) data;
  65.         fprintf(stream, " <");
  66.         if (tag->option & HT_CLOSE)
  67.             fprintf(stream, "/");
  68.         if (tag->o_handle)
  69.             fprintf(stderr, "*");
  70.         fprintf(stream, "%s", tag->name);
  71.         if (tag->c_handle)
  72.             fprintf(stderr, "*");
  73.         if (tag->option & HT_REQUIRED)
  74.             fprintf(stream, "/r");
  75.         if (tag->option & HT_ONLYONCE)
  76.             fprintf(stream, "/1");
  77.         if (tag->option & HT_AUTOCLOSE)
  78.             fprintf(stream, "/sc");
  79.         if (tag->option & HT_SPECIAL)
  80.             fprintf(stream, "/a");
  81.         fprintf(stream, ">");
  82.     }
  83.     else
  84.         fprintf(stream, " <NULL>");
  85. }
  86. #endif
  87.  
  88. /* function to temporarily disable debuggin output */
  89. #if 1
  90. static BOOL dbg_old = FALSE;
  91.  
  92. #define dbg_disable(hp) {dbg_old = hp->debug; hp->debug=FALSE;}
  93. #define dbg_restore(hp) {hp->debug=dbg_old;}
  94.  
  95. #else
  96. #define dbg_disable(hp)
  97. #define dbg_restore(hp)
  98. #endif
  99.  
  100. /*
  101.  * find_prefs_fname
  102.  *
  103.  * find preferences file: first check, if it is located
  104.  * somewhere in the paths given via CONFIG_PATH (which
  105.  * is a system depandent symbol); if not, check if it
  106.  * is in the path described in the envvar HSCPREFS
  107.  *
  108.  * result: full path & filename of prefs or NULL if not found
  109.  */
  110. static STRPTR find_prefs_fname(HSCPRC * hp)
  111. {
  112.     STRPTR prefs_fname = NULL;
  113.     STRPTR paths[] =            /* paths to search for config file */
  114.     {"", "", CONFIG_PATH,
  115.      NULL, NULL};
  116.     STRPTR path = NULL;
  117.     UBYTE path_ctr = 0;
  118.     FILE *cfgf = NULL;          /* prefs file */
  119.     STRPTR hscenv = NULL;
  120.     EXPSTR *hscpathstr = init_estr(32); /* buffer to read $HSCPATH */
  121.  
  122.     static STRARR cfgfn[300];   /* TODO: expstr; buffer to create
  123.                                  *   filename of config file */
  124.     /* setup path from envvar */
  125.     hscenv = getenv(ENV_HSCPATH);
  126.     if (hscenv)
  127.     {
  128. #if 1
  129.         if (link_envfname(hscpathstr, ENV_HSCPATH, NULL, NULL))
  130.         {
  131.             /* add hscenv to paths */
  132.             paths[1] = estr2str(hscpathstr);
  133.         }
  134. #else
  135.         /* copy envvar to own memory area */
  136.         hscenv = strclone(hscenv);
  137.  
  138.         /* strip linefeeds from hscenv */
  139.         while (strlen(hscenv) && (hscenv[strlen(hscenv)] == '\n'))
  140.             hscenv[strlen(hscenv)] = '\0';
  141.  
  142.         /* add hscenv to paths */
  143.         paths[1] = hscenv;
  144. #endif
  145.     }
  146.  
  147.     /* try to open any prefs-file */
  148.     do
  149.     {                           /* loop: */
  150.         path = paths[path_ctr]; /*   get next path */
  151.         if (path)
  152.         {                       /*   is it the last one? */
  153.             strcpy(cfgfn, path);        /*   N->generate filename */
  154.             strcat(cfgfn, CONFIG_FILE);
  155.  
  156.             DC(fprintf(stderr, DHL "try \"%s\"\n", cfgfn));
  157.  
  158.             cfgf = fopen(cfgfn, "r");   /*      try to open file */
  159.         }
  160.         path_ctr++;             /*   process next path */
  161.     }
  162.     while (path && (!cfgf));    /* until no path left or file opened */
  163.  
  164.     if (cfgf)
  165.     {
  166.         prefs_fname = cfgfn;
  167.         fclose(cfgf);
  168.     }
  169.  
  170.     del_estr(hscpathstr);
  171.  
  172.     return (prefs_fname);
  173. }
  174.  
  175. /*
  176.  * hsc_read_base_info
  177.  *
  178.  * try to open base-file and read where in memory
  179.  * information about defined tags/attributes/entities
  180.  * is located.
  181.  *
  182.  * result: dummy-hsc-process that only contains
  183.  *   the information read from base-file
  184.  *
  185.  * see "LoadHscPrefs/LoadHscPrefs.c"
  186.  */
  187. HSCPRC *hsc_read_base_info(VOID)
  188. {
  189.     HSCPRC *dummy_hp = NULL;
  190.  
  191. #ifdef HSCBASE_FILE
  192.  
  193.     FILE *inpf = fopen(HSCBASE_FILE, "r");
  194.     DLLIST *hp_deftag = NULL;
  195.     DLLIST *hp_defattr = NULL;
  196.     DLLIST *hp_defent = NULL;
  197.  
  198.     if (inpf)
  199.     {
  200.         STRARR s[32];
  201.         APTR p = NULL;
  202.  
  203.         while (fscanf(inpf, "%s %p\n", &(s[0]), &p) != EOF)
  204.         {
  205.             if (!strcmp("DEFTAG", s))
  206.             {
  207.                 hp_deftag = (DLLIST *) p;
  208.                 printf(DHL "deftag  %p\n", hp_deftag);
  209.             }
  210.             else if (!strcmp("DEFATTR", s))
  211.             {
  212.                 hp_defattr = (DLLIST *) p;
  213.                 printf(DHL "defattr %p\n", hp_defattr);
  214.             }
  215.             else if (!strcmp("DEFENT", s))
  216.             {
  217.                 hp_defent = (DLLIST *) p;
  218.                 printf(DHL "defent  %p\n", hp_defent);
  219.             }
  220.             else
  221.             {
  222.                 printf(DHL "%s %p (unknown)\n", s, p);
  223.             }
  224.         }
  225.     }
  226.  
  227.     fclose(inpf);
  228.  
  229.     if (hp_deftag && hp_defattr && hp_defent)
  230.     {
  231.         /* assign information to dummy-process */
  232.         dummy_hp = new_hscprc();
  233.  
  234.         del_dllist(dummy_hp->defattr);
  235.         del_dllist(dummy_hp->defent);
  236.         del_dllist(dummy_hp->deftag);
  237.  
  238.         dummy_hp->deftag = hp_deftag;
  239.         dummy_hp->defattr = hp_defattr;
  240.         dummy_hp->defent = hp_defent;
  241.  
  242.         /* assign new del_data-methodes */
  243.         dummy_hp->defattr->del_data = del_hscattr;
  244.         dummy_hp->defent->del_data = del_entity;
  245.         dummy_hp->deftag->del_data = del_hsctag;
  246.     }
  247.  
  248. #endif
  249.     return (dummy_hp);
  250. }
  251.  
  252. BOOL hsc_copy_base_info(HSCPRC * dest_hp, HSCPRC * dummy_hp)
  253. {
  254.     DLNODE *nd = dummy_hp->deftag->first;
  255.  
  256.     /* copy defined tags */
  257.     while (nd)
  258.     {
  259.         HSCTAG *newtag = cpy_hsctag((HSCTAG *) nd->data);
  260.         app_dlnode(dest_hp->deftag, (APTR) newtag);
  261.         nd = nd->next;
  262.     }
  263.  
  264.     return (TRUE);
  265. }
  266.  
  267. /*
  268.  * hsc_read_prefs
  269.  *
  270.  * try to open (any) config file and read preferences
  271.  * from it
  272.  */
  273. BOOL hsc_read_prefs(HSCPRC * hp, STRPTR prefs_fname)
  274. {
  275.     BOOL ok = FALSE;
  276.  
  277.     /* find prefs file */
  278.     if (!prefs_fname)
  279.         prefs_fname = find_prefs_fname(hp);
  280.  
  281.     /* status message */
  282.     if (prefs_fname)
  283.     {
  284.         dbg_disable(hp);
  285.  
  286.         hsc_status_file_begin(hp, prefs_fname);
  287.         ok = hsc_include_file(hp, prefs_fname,
  288.                               IH_PARSE_HSC | IH_NO_STATUS);
  289.         dbg_restore(hp);
  290.  
  291.         if (ok)
  292.         {
  293.             EXPSTR *msg = init_estr(32);
  294.             set_estr(msg, prefs_fname);
  295.             app_estr(msg, ": preferences read");
  296.             hsc_status_misc(hp, estr2str(msg));
  297.             del_estr(msg);
  298.         }
  299.     }
  300.     else
  301.     {
  302.         hsc_message(hp, MSG_NO_CONFIG,
  303.                     "can not open preferences file");
  304.     }
  305.  
  306.     return (ok);
  307. }
  308.  
  309. /*
  310.  * callback to display "project-file corrupt"-message
  311.  */
  312. static VOID msg_corrupt_pf(HSCPRJ * project, STRPTR reason)
  313. {
  314.     STRPTR prjtxt = "project-file corrupt";
  315.     HSCPRC *hp = (HSCPRC *) project->user_data;
  316.  
  317.     if (reason)
  318.         hsc_message(hp, MSG_CORRUPT_PRJFILE, "%s (%s)", prjtxt, reason);
  319.     else
  320.         hsc_message(hp, MSG_CORRUPT_PRJFILE, "%s", prjtxt);
  321. }
  322.  
  323. /*
  324.  * hsc_init_project
  325.  *
  326.  * read project-file
  327.  */
  328. BOOL hsc_init_project(HSCPRC * hp, STRPTR project_fname)
  329. {
  330.     BOOL ok = FALSE;
  331.  
  332.     /* init project */
  333.     hp->project = new_project();
  334.     hp->project->user_data = (APTR) hp;
  335.     hp->project->debug = hp->debug;
  336.     hp->project->CB_msg_corrupt_pf = msg_corrupt_pf;
  337.  
  338.     if (project_fname)
  339.     {
  340.         /*
  341.          * read project-data
  342.          */
  343.         D(fprintf(stderr, DHL "read project-file `%s'\n", project_fname));
  344.  
  345.         hsc_status_file_begin(hp, project_fname);
  346.  
  347.         /* read project-file */
  348.         hp->inpf = infopen(project_fname, 0);
  349.  
  350.         if (hp->inpf)
  351.         {
  352.             ok = hsc_project_read_file(hp->project, hp->inpf);
  353.             infclose(hp->inpf);
  354.             if (ok)
  355.             {
  356.                 /* message about success */
  357.                 EXPSTR *msg = init_estr(32);
  358.                 set_estr(msg, project_fname);
  359.                 app_estr(msg, ": project-file read");
  360.                 hsc_status_misc(hp, estr2str(msg));
  361.                 del_estr(msg);
  362.             }
  363.  
  364.             hp->inpf = NULL;
  365.         }
  366.         else
  367.         {
  368.             D(fprintf(stderr, DHL "  can't read project-file\n"));
  369.             ok = TRUE;
  370.             /* TODO: message "creating new one" */
  371.         }
  372.     }
  373.     else
  374.     {
  375.         D(fprintf(stderr, DHL "no project-file to load\n"));
  376.         ok = TRUE;
  377.     }
  378.  
  379.     if (ok)
  380.     {
  381.         /* dettach current document */
  382.         hsc_project_set_document(hp->project, hp->filename_document);
  383.     }
  384.  
  385.     return (ok);
  386. }
  387.  
  388. /*
  389.  * hsc_set_tagCB
  390.  */
  391. VOID hsc_set_tagCB(HSCPRC * hp, STRPTR name,
  392.                    BOOL(*op_hnd) (HSCPRC * inpf, HSCTAG * tag),
  393.                    BOOL(*cl_hnd) (HSCPRC * inpf, HSCTAG * tag))
  394. {
  395.     HSCTAG *tag = find_strtag(hp->deftag, name);
  396.  
  397.     if (tag && !(tag->option & HT_NOHANDLE))
  398.     {
  399.         /* set handles */
  400.         DC(fprintf(stderr, DHL "add handles for <%s> (%p,%p)\n",
  401.                    name, op_hnd, cl_hnd));
  402.         tag->o_handle = op_hnd;
  403.         tag->c_handle = cl_hnd;
  404.     }
  405. }
  406.  
  407. /*
  408.  * init_hsctags
  409.  *
  410.  * define hsc tags & attributes; assign tagCBs for them
  411.  *
  412.  * NOTE: this ones tricky, but a bit perverted somehow
  413.  */
  414. BOOL hsc_init_tagsNattr(HSCPRC * hp)
  415. {
  416. #define INCLUDE_ATTR " PRE:bool SOURCE:bool TEMPORARY:bool" \
  417.                      " INDENT:num TABSIZE:num=\"4\" "
  418.     BYTE i = 0;
  419.     BOOL ok = TRUE;
  420.     BOOL open_tag;
  421.     HSCTAG *tag;
  422.  
  423.     STRPTR hsc_prefs[] =
  424.     {
  425.     /*
  426.      * define hsc tags
  427.      */
  428.         HSC_COMMENT_STR " /SKIPLF /SPECIAL>",
  429.         HSC_ONLYCOPY_STR " /SPECIAL>",
  430.         HSC_INSEXPR_STR " /SPECIAL>",
  431.         HSC_DEFENT_STR " /SKIPLF NAME:string/r RPLC:string NUM:num>",
  432.         HSC_DEFICON_STR " /SKIPLF NAME:string/r>",
  433.         HSC_DEFINE_STR " /SKIPLF /SPECIAL>",
  434.         HSC_DEFTAG_STR " /SKIPLF /SPECIAL>",
  435.         HSC_ELSE_STR " /SKIPLF /MBI=\"" HSC_IF_STR "\">",
  436.         HSC_ELSEIF_STR " /SKIPLF /MBI=\"" HSC_IF_STR "\"" CONDITION_ATTR ":bool>",
  437.         HSC_MESSAGE_STR " /SKIPLF TEXT:string/r CLASS:enum(\"note|warning|error|fatal\")='note'>",
  438.         HSC_EXEC_STR " /SKIPLF COMMAND:string/r REMOVE:enum(\"on|off|auto\")=\"auto\" ATTRIBUTE:string INCLUDE:bool FILE:string " INCLUDE_ATTR ">",
  439.         HSC_EXPORT_STR " /SKIPLF FILE:string/r DATA:string/r APPEND:bool>",
  440.         HSC_IF_STR " /SKIPLF /CLOSE " CONDITION_ATTR ":bool>",
  441.         HSC_INSERT_STR " /OBSOLETE TEXT:string TIME:bool FORMAT:string>",
  442.         HSC_INCLUDE_STR " /SKIPLF FILE:string/r " INCLUDE_ATTR ">",
  443.         HSC_LET_STR " /SKIPLF /SPECIAL>",
  444.         HSC_MACRO_STR " /SKIPLF /SPECIAL>",
  445.         HSC_SOURCE_STR " /SKIPLF PRE:bool>",
  446.         NULL
  447.     };
  448.  
  449.     STRPTR hsc_attribs[] =
  450.     {
  451.     /*
  452.      * define hsc attributes
  453.      */
  454.         SYSTEM_ATTR ":string/c=\"" SYSTEM_ATTR_ID "\">",
  455.         ANCHOR_ATTR ":string=\"this is a feature, not a bug\">",
  456.         RESULT_ATTR ":num=\"0\">",
  457.         FILESIZEFORMAT_ATTR ":string=\"%a%u\">",
  458.         TIMEFORMAT_ATTR ":string=\"%d-%b-%Y, %H:%M\">",
  459.         LINEFEED_ATTR ":string>",
  460.         NULL};
  461.  
  462.     /* temporarily disable debugging output */
  463.     dbg_disable(hp);
  464.  
  465.     /* define hsc-tags */
  466.     i = 0;
  467.     while (!(hp->fatal) && hsc_prefs[i])
  468.     {
  469.         STRARR infname[20];
  470.  
  471.         sprintf(infname, SPECIAL_FILE_ID "init%3d", i);
  472.         hp->inpf = infopen_str(infname, hsc_prefs[i], 60);
  473.  
  474.         if (hp->inpf)
  475.         {
  476.             tag = def_tag_name(hp, &open_tag);
  477.             ok = (tag && def_tag_args(hp, tag));
  478.             infclose(hp->inpf);
  479.         }
  480.  
  481.         i++;
  482.  
  483.     }
  484.  
  485.     /* init hsc-attributes */
  486.     i = 0;
  487.     while (!(hp->fatal) && hsc_attribs[i])
  488.     {
  489.         hp->inpf =
  490.             infopen_str(SPECIAL_FILE_ID "init attr", hsc_attribs[i], 60);
  491.  
  492.         if (hp->inpf)
  493.         {
  494.             handle_hsc_define(hp, NULL);
  495.             infclose(hp->inpf);
  496.             hp->inpf = NULL;
  497.         }
  498.  
  499.         i++;
  500.     }
  501.  
  502.     /* assign "\n" to linefeed-attribute */
  503.     set_vartext(find_varname(hp->defattr, LINEFEED_ATTR), "\n");
  504.  
  505.     /* assign tag-callbacks to hsc-tags */
  506.     if (ok)
  507.     {
  508.         hsc_set_tagCB(hp, HSC_COMMENT_STR, handle_hsc_comment, NULL);
  509.         hsc_set_tagCB(hp, HSC_DEFENT_STR, handle_hsc_defent, NULL);
  510.         hsc_set_tagCB(hp, HSC_DEFICON_STR, handle_hsc_deficon, NULL);
  511.         hsc_set_tagCB(hp, HSC_DEFINE_STR, handle_hsc_define, NULL);
  512.         hsc_set_tagCB(hp, HSC_DEFTAG_STR, handle_hsc_deftag, NULL);
  513.         hsc_set_tagCB(hp, HSC_ELSE_STR, handle_hsc_else, NULL);
  514.         hsc_set_tagCB(hp, HSC_ELSEIF_STR, handle_hsc_elseif, NULL);
  515.         hsc_set_tagCB(hp, HSC_EXEC_STR, handle_hsc_exec, NULL);
  516.         hsc_set_tagCB(hp, HSC_EXPORT_STR, handle_hsc_export, NULL);
  517.         hsc_set_tagCB(hp, HSC_IF_STR, handle_hsc_if, handle_hsc_cif);
  518.         hsc_set_tagCB(hp, HSC_INCLUDE_STR, handle_hsc_include, NULL);
  519.         hsc_set_tagCB(hp, HSC_INSERT_STR, handle_hsc_insert, NULL);
  520.         hsc_set_tagCB(hp, HSC_INSEXPR_STR, handle_hsc_insert_expression, NULL);
  521.         hsc_set_tagCB(hp, HSC_COMMENT_STR, handle_hsc_comment, NULL);
  522.         hsc_set_tagCB(hp, HSC_LET_STR, handle_hsc_let, NULL);
  523.         hsc_set_tagCB(hp, HSC_MACRO_STR, handle_hsc_macro, NULL);
  524.         hsc_set_tagCB(hp, HSC_MESSAGE_STR, handle_hsc_message, NULL);
  525.         hsc_set_tagCB(hp, HSC_ONLYCOPY_STR, handle_hsc_onlycopy, NULL);
  526.         hsc_set_tagCB(hp, HSC_SOURCE_STR, handle_hsc_source, NULL);
  527.     }
  528.  
  529.     /* restore debugging output */
  530.     dbg_restore(hp);
  531.  
  532.     return (ok);
  533. }
  534.  
  535. /*
  536.  * hsc_init_basicEntities
  537.  *
  538.  * create basic entities (&, >, <, ")
  539.  * (should be called BEFORE hsc_read_prefs())
  540.  */
  541. BOOL hsc_init_basicEntities(HSCPRC * hp)
  542. {
  543.     BOOL ok = TRUE;
  544.  
  545.     /* entities */
  546.     ok &= add_ent(hp->defent, "amp", NULL, 0);  /* & */
  547.     ok &= add_ent(hp->defent, "lt", NULL, 0);   /* < */
  548.     ok &= add_ent(hp->defent, "gt", NULL, 0);   /* > */
  549.     ok &= add_ent(hp->defent, "quot", NULL, 0);         /* q */
  550.  
  551.     return (ok);
  552. }
  553.  
  554. /*
  555.  * hsc_assign_tagCBs
  556.  *
  557.  * assign tag-callbacks to standard html-tags
  558.  * (MUST ONLY be called AFTER hsc_read_prefs())
  559.  */
  560. BOOL hsc_assign_tagCBs(HSCPRC * hp)
  561. {
  562.     hsc_set_tagCB(hp, "!", handle_sgml_comment, NULL);
  563.     hsc_set_tagCB(hp, "A", handle_anchor, handle_canchor);
  564.     hsc_set_tagCB(hp, "BASE", handle_base, NULL);
  565.     hsc_set_tagCB(hp, "BLINK", handle_blink, NULL);
  566.     hsc_set_tagCB(hp, "H1", handle_heading, NULL);
  567.     hsc_set_tagCB(hp, "H2", handle_heading, NULL);
  568.     hsc_set_tagCB(hp, "H3", handle_heading, NULL);
  569.     hsc_set_tagCB(hp, "H4", handle_heading, NULL);
  570.     hsc_set_tagCB(hp, "H5", handle_heading, NULL);
  571.     hsc_set_tagCB(hp, "H6", handle_heading, NULL);
  572.     hsc_set_tagCB(hp, "IMG", handle_img, NULL);
  573.     hsc_set_tagCB(hp, "PRE", handle_pre, handle_end_pre);
  574.  
  575.     return (TRUE);
  576. }
  577.  
  578. /*
  579.  * hsc_init_hscprc
  580.  *
  581.  * - init all items of hsc-process
  582.  * - create hsc-tags & special atttributes
  583.  * - read preferences file
  584.  * - assign tag-callbacks
  585.  */
  586. BOOL hsc_init_hscprc(HSCPRC * hp, STRPTR prefs_fname)
  587. {
  588.     BOOL ok = FALSE;            /* return value */
  589.  
  590.     if (hsc_init_tagsNattr(hp)
  591.         && hsc_init_basicEntities(hp)
  592.         && hsc_read_prefs(hp, prefs_fname)
  593.         && hsc_assign_tagCBs(hp)
  594.         )
  595.     {
  596.         /* return sucess */
  597.         ok = TRUE;
  598.  
  599.         /* printf list of defined tags & entities */
  600.         DC(
  601.               {
  602.               DLNODE * nd;
  603.               HSCENT * ent;
  604.  
  605.               nd = hp->defent->first;
  606.               if (nd)
  607.               {
  608.               fprintf(stderr, DHL "Known entities:");
  609.  
  610.               while (nd)
  611.               {
  612.               ent = (HSCENT *) nd->data;
  613.               fprintf(stderr, " &%s;", ent->name);
  614.               nd = nd->next;
  615.               }
  616.               fprintf(stderr, "\n");
  617.               }
  618.  
  619.               nd = hp->deftag->first;
  620.               if (nd)
  621.               {
  622.               fprintf(stderr, DHL "Known tags:");
  623.               while (nd)
  624.               {
  625.               prt_tag(stderr, nd->data);
  626.               nd = nd->next;
  627.               }
  628.               fprintf(stderr, "\n");
  629.               }
  630.  
  631.               }
  632.         );                      /* DC */
  633.     }
  634.  
  635.     hp->click_here_str =
  636.         get_vartext_byname(hp->defattr, CLICK_HERE_ATTR);
  637.     hp->color_names =
  638.         get_vartext_byname(hp->defattr, COLOR_NAMES_ATTR);
  639.  
  640.     return (ok);
  641. }
  642.  
  643.